package seed_system

import (
	"fmt"
	"gitee.com/theegg/go-brick/app/model/system/system_configures"
	"gitee.com/theegg/go-brick/app/service/app"
)

func InitSystemConfiguresSeed() {
	items := make(map[int]system_configures.SystemConfigures)

	items[1000] = system_configures.SystemConfigures{
		Id:            1000,
		Pid:           0,
		Title:         "网站",
		Sign:          "site",
		ConfigureType: "empty",
		Value:         "",
		Mark:          "",
		Status:        true,
	}

	items[2000] = system_configures.SystemConfigures{
		Id:            2000,
		Pid:           0,
		Title:         "用户",
		ConfigureType: "empty",
		Sign:          "user",
		Value:         "",
		Mark:          "",
		Status:        true,
	}

	items[3000] = system_configures.SystemConfigures{
		Id:            3000,
		Pid:           0,
		Title:         "城市综合",
		ConfigureType: "empty",
		Sign:          "urban",
		Value:         "",
		Mark:          "城市综合",
		Status:        true,
	}

	items[1001] = system_configures.SystemConfigures{
		Id:            1001,
		Pid:           1000,
		Title:         "网站标题",
		Sign:          "site_title",
		Value:         "go-brick",
		ConfigureType: "string",
		Mark:          "",
		Status:        true,
	}

	items[3001] = system_configures.SystemConfigures{
		Id:            3001,
		Pid:           3000,
		Title:         "城市综合-国家",
		Sign:          "urban_country",
		ConfigureType: "string",
		Value:         "cn",
		Mark:          "",
		Status:        true,
	}

	count := 0
	errCount := 0
	for _, item := range items {
		_, err := app.Db().Insert(item)
		if err != nil {
			fmt.Println(err.Error())
			errCount++
		} else {
			count++
		}
	}

	fmt.Printf("%5s|%25s|%10d|%8d|\n", "", "system_configures", count, errCount)
}
